package com.butterfly.common.utils;

import com.butterfly.common.enums.BaseErrorEnum;
import com.butterfly.common.model.SoaResponse;

public class SoaResponseUtil {
    public static  <T> SoaResponse<T> success(T data) {
        SoaResponse<T> soaResponse = new SoaResponse<>();
        soaResponse.setCode(BaseErrorEnum.SUCCESS.getCode());
        soaResponse.setMsg(BaseErrorEnum.SUCCESS.getMsg());
        soaResponse.setData((T)data);
        return soaResponse;
    }

    public static  SoaResponse<Void> success() {
        SoaResponse<Void> soaResponse = new SoaResponse<>();
        soaResponse.setCode(BaseErrorEnum.SUCCESS.getCode());
        soaResponse.setMsg(BaseErrorEnum.SUCCESS.getMsg());
        return soaResponse;
    }

    public static  SoaResponse<Void> failure(BaseErrorEnum baseErrorEnum) {
        SoaResponse<Void> soaResponse = new SoaResponse<>();
        soaResponse.setCode(baseErrorEnum.getCode());
        soaResponse.setMsg(baseErrorEnum.getMsg());
        return soaResponse;
    }

    public static  SoaResponse<Void> failure() {
        SoaResponse<Void> soaResponse = new SoaResponse<>();
        soaResponse.setCode(BaseErrorEnum.BUSINESS_ERROR.getCode());
        soaResponse.setMsg(BaseErrorEnum.BUSINESS_ERROR.getMsg());
        return soaResponse;
    }

    public static  <T>SoaResponse<T> failure(T data ,Integer code,String msg) {
        SoaResponse<T> soaResponse = new SoaResponse<>();
        soaResponse.setCode(code);
        soaResponse.setMsg(msg);
        return soaResponse;
    }
}
